import {BasicColumn} from '/@/components/Table';
import {FormSchema} from '/@/components/Table';
import { rules} from '/@/utils/helper/validator';
import { render } from '/@/utils/common/renderUtils';
//列表数据
export const columns: BasicColumn[] = [
  {
    title: '案例编号',
    align: "center",
    sorter: true,
    dataIndex: 'caseNo',
    resizable: true,
  },
  {
    title: '批次',
    align: "center",
    sorter: true,
    dataIndex: 'batchId_dictText'
  },
  {
    title: '测试阶段',
    align: "center",
    sorter: true,
    dataIndex: 'testStageId_dictText'
  },
  {
    title: '系统',
    align: "center",
    sorter: true,
    dataIndex: 'systemId_dictText'
  },
  // {
  //   title: '关联功能',
  //   align: "center",
  //   sorter: true,
  //   dataIndex: 'functionId_dictText'
  // },
  {
    title: '功能名称',
    align: "center",
    sorter: true,
    dataIndex: 'functionName',
    resizable: true,
  },
  {
    title: '测试方法',
    align: "center",
    sorter: true,
    dataIndex: 'testMethod_dictText'
  },
  {
    title: '测试目的',
    align: "center",
    sorter: true,
    dataIndex: 'caseName'
  },
  {
    title: '前提条件',
    align: "center",
    sorter: true,
    dataIndex: 'prerequisite'
  },
  {
    title: '数据需求',
    align: "center",
    sorter: true,
    dataIndex: 'dataRequire'
  },
  {
    title: '操作步骤',
    align: "center",
    sorter: true,
    dataIndex: 'description'
  },
  {
    title: '预期结果',
    align: "center",
    sorter: true,
    dataIndex: 'expectResult'
  },
  {
    title: '实际结果描述',
    align: "center",
    sorter: true,
    dataIndex: 'actualResult'
  },
  {
    title: '截图上传',
    align: "center",
    dataIndex: 'executeRecordPic',
    customRender: render.renderImage,
  },
  {
    title: '执行状态',
    align: "center",
    sorter: true,
    dataIndex: 'caseExecuteStatus'
  },
  {
    title: '编写人',
    align: "center",
    sorter: true,
    dataIndex: 'caseAuthor_dictText'
  },
  {
    title: '执行人',
    align: "center",
    sorter: true,
    dataIndex: 'caseExecutor_dictText'
  },
  {
    title: '复核人',
    align: "center",
    sorter: true,
    dataIndex: 'caseReviewer_dictText'
  },
  {
    title: '执行日期',
    align: "center",
    sorter: true,
    dataIndex: 'executeTime'
  },
  {
    title: '案例状态',
    align: "center",
    sorter: true,
    dataIndex: 'caseStatus'
  },
];

//查询数据
export const searchFormSchema: FormSchema[] = [
  {
    label: "案例编号",
    field: 'caseNo',
    component: 'Input',
    //colProps: {span: 6},
  },
  {
    label: "功能名称",
    field: 'functionName',
    component: 'Input',
    //colProps: {span: 6},
  },
  {
    label: "测试方法",
    field: 'testMethod',
    component: 'JDictSelectTag',
    componentProps:{
      dictCode: "test_methods"
    },
    //colProps: {span: 6},
  },
  {
    label: "测试目的",
    field: 'caseName',
    component: 'Input',
    //colProps: {span: 6},
  },
  {
    label: "执行状态",
    field: 'caseExecuteStatus',
    component: 'Input',
    //colProps: {span: 6},
  },
  {
    label: "编写人",
    field: 'caseAuthor',
    component: 'JSelectUser',
    //colProps: {span: 6},
  },
  {
    label: "执行人",
    field: 'caseExecutor',
    component: 'JSelectUser',
    //colProps: {span: 6},
  },
  {
    label: "复核人",
    field: 'caseReviewer',
    component: 'JSelectUser',
    //colProps: {span: 6},
  },
  {
    label: "标签展示",
    field: 'tag',
    component: 'Input',
    //colProps: {span: 6},
  },
  {
    label: "案例状态",
    field: 'caseStatus',
    component: 'Input',
    //colProps: {span: 6},
  },
  {
    label: "更新人",
    field: 'updateBy',
    component: 'Input',
    //colProps: {span: 6},
  },
];

//表单数据
export const formSchema: FormSchema[] = [
  {
    label: '案例编号',
    field: 'caseNo',
    component: 'Input',
    dynamicDisabled: true
  },
  {
    label: '功能名称',
    field: 'functionName',
    component: 'Input',
    dynamicDisabled: true
  },
  {
    label: '测试方法',
    field: 'testMethod',
    component: 'JDictSelectTag',
    componentProps:{
      dictCode: "test_methods"
    },
    dynamicDisabled: true
  },
  {
    label: '测试目的',
    field: 'caseName',
    component: 'InputTextArea',
    dynamicRules: ({model,schema}) => {
      return [
              { required: true, message: '请输入测试目的!'},
             ];
    },
  },
  {
    label: '前提条件',
    field: 'prerequisite',
    component: 'InputTextArea',
  },
  {
    label: '数据需求',
    field: 'dataRequire',
    component: 'InputTextArea',
  },
  {
    label: '操作步骤',
    field: 'description',
    component: 'InputTextArea',
    dynamicRules: ({model,schema}) => {
      return [
              { required: true, message: '请输入操作步骤!'},
             ];
    },
  },
  {
    label: '预期结果',
    field: 'expectResult',
    component: 'InputTextArea',
    dynamicRules: ({model,schema}) => {
      return [
              { required: true, message: '请输入预期结果!'},
             ];
    },
  },
  {
    label: '实际结果描述',
    field: 'actualResult',
    component: 'InputTextArea',
    dynamicRules: ({model,schema}) => {
      return [
              { required: true, message: '请输入实际结果描述!'},
             ];
    },
  },
  {
    label: '截图上传',
    field: 'executeRecordPic',
    component: 'JImageUpload',
    componentProps:{
    },
  },
	// TODO 主键隐藏字段，目前写死为ID
  {
    label: '',
    field: 'id',
    component: 'Input',
    show: false,
  },
];

// 高级查询数据
export const superQuerySchema = {
  caseNo: {title: '案例编号',order: 0,view: 'text', type: 'string',},
  functionName: {title: '功能名称',order: 1,view: 'text', type: 'string',},
  testMethod: {title: '测试方法',order: 2,view: 'list', type: 'string',dictCode: 'test_methods',},
  caseName: {title: '测试目的',order: 3,view: 'textarea', type: 'string',},
  prerequisite: {title: '前提条件',order: 4,view: 'textarea', type: 'string',},
  dataRequire: {title: '数据需求',order: 5,view: 'textarea', type: 'string',},
  description: {title: '操作步骤',order: 6,view: 'textarea', type: 'string',},
  expectResult: {title: '预期结果',order: 7,view: 'textarea', type: 'string',},
  actualResult: {title: '实际结果描述',order: 8,view: 'textarea', type: 'string',},
  executeRecordPic: {title: '截图上传',order: 9,view: 'image', type: 'string',},
  caseExecuteStatus: {title: '执行状态',order: 10,view: 'text', type: 'string',},
  caseAuthor: {title: '编写人',order: 11,view: 'sel_user', type: 'string',},
  caseExecutor: {title: '执行人',order: 12,view: 'sel_user', type: 'string',},
  caseReviewer: {title: '复核人',order: 13,view: 'sel_user', type: 'string',},
  executeTime: {title: '执行日期',order: 15,view: 'datetime', type: 'string',},
  caseStatus: {title: '案例状态',order: 16,view: 'text', type: 'string',},
};
